home *** CD-ROM | disk | FTP | other *** search
/ Windows Game Programming for Dummies (2nd Edition) / WinGamProgFD.iso / mac / DirectX SDK / DXSDK / samples / Multimedia / Direct3D / BumpMapping / DotProduct3 / readme.txt < prev    next >
Text File  |  2001-10-10  |  3KB  |  63 lines

  1. //-----------------------------------------------------------------------------
  2. // Name: DotProduct3 Direct3D Sample
  3. // 
  4. // Copyright (c) 1998-2001 Microsoft Corporation. All rights reserved.
  5. //-----------------------------------------------------------------------------
  6.  
  7.  
  8. Description
  9. ===========
  10.   The DotProduct3 samples demonstrates an alternative approach to Direct3D
  11.   bumpmapping. This technique is named after the mathematical operation which
  12.   combines a light vector with a surface normal. The normals for a surface are
  13.   traditional (x,y,z) vectors stored in RGBA format in a texture map (called a
  14.   normal map, for this technique).
  15.  
  16.   Not all cards support DotProduct3 blending teture stages, but then not all
  17.   cards support Direct3D bumpmapping. Refer to the DirectX SDK documentation
  18.   for more information.
  19.  
  20.  
  21. Path
  22. ====
  23.    Source:     DXSDK\Samples\Multimedia\D3D\BumpMapping\DotProduct3
  24.    Executable: DXSDK\Samples\Multimedia\D3D\Bin
  25.  
  26.  
  27. User's Guide
  28. ============
  29.    The following keys are implemented. The dropdown menus can be used for the
  30.    same controls.
  31.       <Enter>     Starts and stops the scene
  32.       <Space>     Advances the scene by a small increment
  33.       <F1>        Shows help or available commands.
  34.       <F2>        Prompts user to select a new rendering device or display mode
  35.       <Alt+Enter> Toggles between fullscreen and windowed modes
  36.       <Esc>       Exits the app.
  37.  
  38.  
  39. Programming Notes
  40. =================
  41.    The lighting equation for simulating bump mapping invloves using the dot
  42.    product of the surface normal and the lighting vector. The lighting vector
  43.    is simply passed into the texture factor, and the normals are encoded in a
  44.    texture map. The blend stages, then, look like
  45.        SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_DOTPRODUCT3 );
  46.        SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
  47.        SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_TFACTOR );
  48.  
  49.    The only trick then, is getting the normals stored in the texture. To do
  50.    this, the components of a vector (XYZW) are each turned from a 32-bit
  51.    floating value into a signed 8-bit integer and packed into a texture color
  52.    (RGBA). The code show how to do this using a custom-generated normal map,
  53.    as well as one built from an actual bumpmapping texture image.
  54.  
  55.    Note that not all cards support all features for all the various bumpmapping
  56.    techniques (some hardware has no, or limited, bumpmapping support). For more
  57.    information on bumpmapping, refer to the DirectX SDK documentation. 
  58.  
  59.    This sample makes use of common DirectX code (consisting of helper functions,
  60.    etc.) that is shared with other samples on the DirectX SDK. All common
  61.    headers and source code can be found in the following directory:
  62.       DXSDK\Samples\Multimedia\Common
  63.